package cn.lopr.im.android.common;

/**
 * @author shuangyang7
 * @date 2020/12/30 13:00
 */
public class Constant {

    public static final String JWT_KEY = "cn.lopr.im.api";
    public static final String NOTIFICATION_ID = "10086";

    public static final String CALLBACK_ERROR_MESSAGE = "我们出现了一些错误，请重试";
    public static final String PARAM_ERROR_MESSAGE = "请填写所有内容";
    public static final String NETWORK_ERROR_MESSAGE = "请检查网络连接";


    public static int GRIVIEW_COLUMN_HEIGHT = 0;// griview设置的高度
    public static int GRIVEW_COLUMN_NUMS = 4;// 列数

    public enum ResponseCode {
        SUCCESS(0, "success"),
        ERROR(1, "error"),
        NEED_LOGIN(10, "NEED_LOGIN"),
        ILLEGAL_ARGUMENT(2, "ILLEGAL_ARGUMENT");

        int code;
        String desc;

        ResponseCode(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static String getDescByCode(int errorCode) {
            for (ResponseCode value : values()) {
                if (value.code == errorCode) {
                    return value.desc;
                }
            }
            return null;
        }
    }

    public enum MessageType {
        USER_ONLINE(0, "用户上线"),
        SEND_TO_USER(1, "发送给用户"),
        SEND_TO_GROUP(2, "发送给组"),
        DEL(100, "删除"),
        SEND_ADD(3, "发送添加好友信息");

        private final int code;
        private final String desc;

        MessageType(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static MessageType getTypeByCode(int code) {
            for (MessageType value : values()) {
                if (value.getCode() == code) {
                    return value;
                }
            }

            return null;
        }
    }
}

